/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.webhomesites.padrao.view;

import br.com.webhomesites.padrao.model.ClienteModel;
import java.awt.event.ActionListener;
import java.awt.event.FocusListener;
import java.util.List;
import javax.swing.JComboBox;

/**
 *
 * @author Webhome
 */
public class BuscarClienteView extends javax.swing.JDialog {

    /**
     * Creates new form BuscarClienteView
     */
    public BuscarClienteView(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        painelBuscaProduto = new javax.swing.JPanel();
        comboCodigo = new javax.swing.JComboBox();
        comboNome = new javax.swing.JComboBox();
        comboCPF = new javax.swing.JComboBox();
        labelCodigo = new javax.swing.JLabel();
        labelNome = new javax.swing.JLabel();
        labelCPF = new javax.swing.JLabel();
        comboRG = new javax.swing.JComboBox();
        labelRG = new javax.swing.JLabel();
        comboCNPJ = new javax.swing.JComboBox();
        labelCNPJ = new javax.swing.JLabel();
        labelInscricaoEstadual = new javax.swing.JLabel();
        comboInscricaoEstadual = new javax.swing.JComboBox();
        btnBuscar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        painelBuscaProduto.setBorder(javax.swing.BorderFactory.createTitledBorder("Buscar Cliente"));

        comboCodigo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecionar" }));

        comboNome.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecionar" }));
        comboNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboNomeActionPerformed(evt);
            }
        });

        comboCPF.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecionar" }));
        comboCPF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboCPFActionPerformed(evt);
            }
        });

        labelCodigo.setText("Código");

        labelNome.setText("Nome");

        labelCPF.setText("CPF");

        comboRG.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecionar" }));
        comboRG.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboRGActionPerformed(evt);
            }
        });

        labelRG.setText("RG");

        comboCNPJ.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecionar" }));
        comboCNPJ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboCNPJActionPerformed(evt);
            }
        });

        labelCNPJ.setText("CNPJ");

        labelInscricaoEstadual.setText("Inscrição Estadual");

        comboInscricaoEstadual.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecionar" }));
        comboInscricaoEstadual.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboInscricaoEstadualActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout painelBuscaProdutoLayout = new javax.swing.GroupLayout(painelBuscaProduto);
        painelBuscaProduto.setLayout(painelBuscaProdutoLayout);
        painelBuscaProdutoLayout.setHorizontalGroup(
            painelBuscaProdutoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelBuscaProdutoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(painelBuscaProdutoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(comboCPF, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(comboCNPJ, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, painelBuscaProdutoLayout.createSequentialGroup()
                        .addGroup(painelBuscaProdutoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelCodigo)
                            .addComponent(labelNome)
                            .addComponent(labelCPF)
                            .addComponent(comboCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelRG)
                            .addComponent(labelCNPJ)
                            .addComponent(labelInscricaoEstadual))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(comboInscricaoEstadual, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(comboNome, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(comboRG, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        painelBuscaProdutoLayout.setVerticalGroup(
            painelBuscaProdutoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelBuscaProdutoLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(labelCodigo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(comboCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(labelNome)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(comboNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(labelCPF)
                .addGap(7, 7, 7)
                .addComponent(comboCPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(17, 17, 17)
                .addComponent(labelRG)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(comboRG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(labelCNPJ)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(comboCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(labelInscricaoEstadual)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(comboInscricaoEstadual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnBuscar.setText("Buscar");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 389, Short.MAX_VALUE)
                        .addComponent(btnBuscar))
                    .addComponent(painelBuscaProduto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(painelBuscaProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnBuscar)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void comboCPFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboCPFActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_comboCPFActionPerformed

    private void comboNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboNomeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_comboNomeActionPerformed

    private void comboRGActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboRGActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_comboRGActionPerformed

    private void comboCNPJActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboCNPJActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_comboCNPJActionPerformed

    private void comboInscricaoEstadualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboInscricaoEstadualActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_comboInscricaoEstadualActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(BuscarClienteView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(BuscarClienteView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(BuscarClienteView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(BuscarClienteView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the dialog
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                BuscarClienteView dialog = new BuscarClienteView(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscar;
    private javax.swing.JComboBox comboCNPJ;
    private javax.swing.JComboBox comboCPF;
    private javax.swing.JComboBox comboCodigo;
    private javax.swing.JComboBox comboInscricaoEstadual;
    private javax.swing.JComboBox comboNome;
    private javax.swing.JComboBox comboRG;
    private javax.swing.JLabel labelCNPJ;
    private javax.swing.JLabel labelCPF;
    private javax.swing.JLabel labelCodigo;
    private javax.swing.JLabel labelInscricaoEstadual;
    private javax.swing.JLabel labelNome;
    private javax.swing.JLabel labelRG;
    private javax.swing.JPanel painelBuscaProduto;
    // End of variables declaration//GEN-END:variables

    public void packAndShow() {
        this.pack();
        this.setVisible(true);
    }

    public Long getComboCodigo() {
        return Long.parseLong(comboCodigo.getSelectedItem().toString());
    }

    public void setComboCodigo(String comboCodigo) {
        this.comboCodigo.setSelectedItem(comboCodigo);
    }

    public String getComboNome() {
        return comboNome.getSelectedItem().toString();
    }

    public void setComboNome(String comboNome) {
        this.comboNome.setSelectedItem(comboNome);
    }

    public String getComboCpf() {
        return comboCPF.getSelectedItem().toString();
    }

    public void setComboCpf(String comboCpf) {
        this.comboCPF.setSelectedItem(comboCpf);
    }
    
    public String getComboRg() {
        return comboRG.getSelectedItem().toString();
    }

    public void setComboRg(String comboRg) {
        this.comboRG.setSelectedItem(comboRg);
    }

    public String getComboCnpj() {
        return comboCNPJ.getSelectedItem().toString();
    }

    public void setComboCnpj(String comboCnpj) {
        this.comboCNPJ.setSelectedItem(comboCnpj);
    }
    
    public String getComboInscricaoEstadual() {
        return comboInscricaoEstadual.getSelectedItem().toString();
    }

    public void setComboInscricaoEstadual(String comboInscricaoEstadual) {
        this.comboInscricaoEstadual.setSelectedItem(comboInscricaoEstadual);
    }
    
    public void setListaCodigo(List<ClienteModel> listaClienteModel) {
        comboCodigo.removeAllItems();
        for (int i = 0; i < listaClienteModel.size(); i++) // Percorro o Array List com o For aprimorado.  
        {
            this.comboCodigo.addItem(listaClienteModel.get(i).getId()); // Adiciono os dados.  
        }
    }

    public void setListaNome(List<ClienteModel> listaClienteModel) {
        comboNome.removeAllItems();
        for (int i = 0; i < listaClienteModel.size(); i++) // Percorro o Array List com o For aprimorado.  
        {
            this.comboNome.addItem(listaClienteModel.get(i).getNome()); // Adiciono os dados.  
        }
    }

    public void setListaCpf(List<ClienteModel> listaClienteModel) {
        comboCPF.removeAllItems();

        for (int i = 0; i < listaClienteModel.size(); i++) // Percorro o Array List com o For aprimorado.  
        {
            if (listaClienteModel.get(i).getCpf()!=null) {
                this.comboCPF.addItem(listaClienteModel.get(i).getCpf()); // Adiciono os dados.  
            }
        }
    }
    
    public void setListaRg(List<ClienteModel> listaClienteModel) {
        comboRG.removeAllItems();

        for (int i = 0; i < listaClienteModel.size(); i++) // Percorro o Array List com o For aprimorado.  
        {
            if (listaClienteModel.get(i).getRg()!=null) {
                this.comboRG.addItem(listaClienteModel.get(i).getRg()); // Adiciono os dados.  
            }
        }
    }
    
    public void setListaCnpj(List<ClienteModel> listaClienteModel) {
        comboCNPJ.removeAllItems();

        for (int i = 0; i < listaClienteModel.size(); i++) // Percorro o Array List com o For aprimorado.  
        {
            if (listaClienteModel.get(i).getCnpj()!=null) {
                this.comboCNPJ.addItem(listaClienteModel.get(i).getCnpj()); // Adiciono os dados.  
            }
        }
    }
    
    public void setListaInscricaoEstadual(List<ClienteModel> listaClienteModel) {
        comboInscricaoEstadual.removeAllItems();

        for (int i = 0; i < listaClienteModel.size(); i++) // Percorro o Array List com o For aprimorado.  
        {
            if (listaClienteModel.get(i).getCpf()!=null) {
                this.comboInscricaoEstadual.addItem(listaClienteModel.get(i).getInscricaoEstadual()); // Adiciono os dados.  
            }
        }
    }

    public void setCodigoFocusListener(FocusListener listener) {
        comboCodigo.addFocusListener(listener);
    }

    public void setNomeFocusListener(FocusListener listener) {
        comboNome.addFocusListener(listener);
    }

    public void setCpfFocusListener(FocusListener listener) {
        comboCPF.addFocusListener(listener);
    }
    
    public void setRgFocusListener(FocusListener listener) {
        comboRG.addFocusListener(listener);
    }
    
    public void setCnpjFocusListener(FocusListener listener) {
        comboCNPJ.addFocusListener(listener);
    }
    
    public void setInscricaoEstadualFocusListener(FocusListener listener) {
        comboInscricaoEstadual.addFocusListener(listener);
    }

    public void setBtnBuscarActionListener(ActionListener listener) {
        btnBuscar.addActionListener(listener);
    }

    public JComboBox getComboCodigoJCombo() {
        return comboCodigo;
    }

    public JComboBox getComboNomeJCombo() {
        return comboNome;
    }

    public JComboBox getComboCpfJCombo() {
        return comboCPF;
    }
    
    public JComboBox getComboRgJCombo() {
        return comboRG;
    }
    
    public JComboBox getComboCnpjJCombo() {
        return comboCNPJ;
    }
    
    public JComboBox getComboInscricaoEstadualJCombo() {
        return comboInscricaoEstadual;
    }

    public void comboCodigoRemoveAllItens() {
        comboCodigo.removeAllItems();
    }

    public void comboNomeRemoveAllItens() {
        comboNome.removeAllItems();
    }

    public void comboCpfRemoveAllItens() {
        comboCPF.removeAllItems();
    }
    
    public void comboRgRemoveAllItens() {
        comboRG.removeAllItems();
    }
    
    public void comboCNPJRemoveAllItens() {
        comboCNPJ.removeAllItems();
    }
    
    public void comboInscricaoEstadualRemoveAllItens() {
        comboInscricaoEstadual.removeAllItems();
    }
}
